/*
 * @Author: Hzt
 * @Date: 2024-06-24 22:21:51
 * @LastEditTime: 2024-06-24 22:24:10
 * @LastEditors: Hzt
 * @Description: 
 * @FilePath: /cty_admin/src/utils/js-beautif-libs/http.js
 */
export function responseFun(a, b, c) {
  const res = a.data;
  if (~a.config.url.indexOf("cty/login")) {
    res.token = a.headers.passport;
  }
  if (res.code === 401 || res.code === 51507) {
    b.dispatch("user/logout");
    b.dispatch("user/resetToken").then(function () {
      location.reload();
    });
    return;
  } else if (res.code !== 200) {
    c({
      message: res.message || "Error",
      type: "error",
      duration: 5 * 1000,
    });
    return Promise.reject(new Error(res.message || "Error"));
  } else {
    return res;
  }
}
